import {ddSyncAddressBook} from '@/api/manager'
import {CnNormalSpan} from '@/components/text'
import {useLoading} from '@/hooks/loading'
import useGlobalAPI from '@/hooks/useGlobalAPI'
import { defineComponent, computed } from 'vue'

export default defineComponent({
  name: 'CBC-home',
  setup(props, ctx) {
    const {router, store} = useGlobalAPI()
    const loginUserInfo = computed(() => store.getters['dingding/ddUserInfo'])
    const {loading, startLoading, closeLoading} = useLoading()
    return () => (
      <div class='w-full h-full flex items-center justify-center relative'>
        <a-spin spinning={loading.value}>
          <div class='flex items-center justify-center gap-x-96'>
            <a-button
              class='w-133 h-133 rounded-full flex flex-col items-center justify-center bg-primary text-white '
              type='primary'
              onClick={() => {
                router.push('/initiateAssessment')
              }}
            >
              <i class='iconfont icon-fenxiang2 text-42'></i>
              <CnNormalSpan class='text-14 text-white'>发起考核</CnNormalSpan>
            </a-button>

            <a-button
              class='w-133 h-133 rounded-full flex flex-col items-center justify-center  bg-primary text-white'
              type='primary'
              onClick={() => {
               
                router.push('/assessmentInitiated/home')
              }}
            >
              <i class='iconfont icon-jianli text-42'></i>

              <CnNormalSpan class='text-14 text-white'>发起评分</CnNormalSpan>
            </a-button>
          </div>
        </a-spin>
        <a-button
          class='absolute bottom-16 right-32 text-14 bg-primaryHalf text-white'
          onClick={() => {
            startLoading()
            ddSyncAddressBook({
              userDDId: loginUserInfo.value.userId
            })
              .then(res => {
                closeLoading()
              })
              .catch(err => {
                closeLoading()
              })
          }}
        >
          更新通讯录
        </a-button>
      </div>
    )
  }
})
